//只负责网络请求
import { get, post, put, del } from "@/request";

export interface IShift {
  shiftId?: number | string | null;
  shiftName: string;
  startTime: string;
  endTime: string;
  workingHours?: number;
  status: number; // 0-删除,1-正常
  deptId?: number | null;
  createTime?: string;
  updateTime?: string;
}

interface IPaginationResponse<T> {
  content: T[];
  totalElements: number;
}

interface IListParams {
  shiftName?: string;
  deptId: number;  
  page: number;    
  size: number;
}

// 获取班次列表
export const fetchShifts = (params: IListParams) => {
  return get<{ data: IPaginationResponse<IShift> }>("/schedule/shift", { params });
};

// 新增班次
export const createShift = (data: IShift) => {
  return post("/schedule/shift", data);
};

// 更新班次
export const updateShift = (data: IShift) => {
  return put("/schedule/shift", data);
};

// 删除班次
export const deleteShift = (id: number) => {
  return del(`/schedule/shift/${id}`);
};

//根据科室id查询班次信息
export const getShiftsByDeptId = (deptId: number) => {
  return get(`/schedule/shift/${deptId}/1`)
}